package com.deductive.service.special.special_import.tool;

import lombok.Data;

import java.time.LocalDateTime;

@Data
public class AsyncTaskStatus {
    private String taskId;
    private String taskType;  // GEO_PUBLISH 或 NEO4J_SYNC
    private String status;    // PENDING, RUNNING, COMPLETED, FAILED
    private String message;
    private LocalDateTime startTime;
    private LocalDateTime endTime;
    private String result;
    
    public AsyncTaskStatus(String taskId, String taskType) {
        this.taskId = taskId;
        this.taskType = taskType;
        this.status = "PENDING";
        this.startTime = LocalDateTime.now();
    }
    
    public void markAsRunning() {
        this.status = "RUNNING";
    }
    
    public void markAsCompleted(String result) {
        this.status = "COMPLETED";
        this.result = result;
        this.endTime = LocalDateTime.now();
    }
    
    public void markAsFailed(String errorMessage) {
        this.status = "FAILED";
        this.message = errorMessage;
        this.endTime = LocalDateTime.now();
    }
    
    public boolean isCompleted() {
        return "COMPLETED".equals(this.status);
    }
}